﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DAL;
using Entities;
using BUS;
using Utility;

public partial class A_LetsDeal_DoanhNghiep_doimatkhau : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["username_dn"] != null)
            {
                Tbl_DoanhNghiep_Entities dn = Tbl_DoanhNghiep_BUS.GetByName(Session["username_dn"].ToString());
                lit_tendn.Text = dn.TenDN;
                lit_tentk.Text = dn.TaiKhoan;
            }
            else
            {
                Response.Redirect("~/A_LetsDeal-DoanhNghiep/Default.aspx");
            }
        }
        
    }
    protected void bt_ok_Click(object sender, EventArgs e)
    {
        Tbl_DoanhNghiep_Entities dn = Tbl_DoanhNghiep_BUS.GetByName(Session["username_dn"].ToString());
        if (txt_mkold.Text == dn.MatKhau)
        {
            Tbl_DoanhNghiep_Entities doanhnghiep = new Tbl_DoanhNghiep_Entities();
            doanhnghiep.STT = dn.STT;
            doanhnghiep.MatKhau = txt_mknew.Text;
            Tbl_DoanhNghiep_BUS.Update_MK(doanhnghiep);
            hyp_thongbao.Text = "Đổi mật khẩu thành công!";
            hyp_thongbao.NavigateUrl = "~/A_LetsDeal-DoanhNghiep/Default.aspx";
        }
        else
        {
            hyp_thongbao.Text = "Sai mật khẩu";
            hyp_thongbao.NavigateUrl = "#";
        }
    }
}
